home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / noweb / src / c / modules.h < prev    next >
C/C++ Source or Header  |  1995-02-28  |  1KB  |  38 lines

  1. typedef struct location {       /* identify lines of source */
  2.     char *filename;
  3.     int lineno;
  4. } Location;
  5.  
  6. typedef enum parttype {STRING=1, MODULE, NEWLINE} Parttype;
  7.  
  8. struct modpart {
  9.     Parttype ptype;             /* type of fragment: STRING, MODULE, NEWLINE */
  10.     char *contents;
  11.     Location loc;               /* for String, where's it from ? */
  12.     struct modpart *next;
  13. };
  14. typedef struct module {
  15.     char *name;
  16.     int usecount;
  17.     struct modpart *head, *tail;
  18. } *Module;
  19. Module newmodule(char *modname);         /* create a new, blank module */
  20. #define addstring(MP,S,L) add_part(MP,S,STRING,&L)
  21.         /* add a string to a module definition (stripping final newline) */
  22. #define addmodule(MP,S) add_part(MP,S,MODULE,0)
  23.         /* add a module reference to a module definition (stripping final newline) */
  24. #define addnewline(MP) add_part(MP,0,NEWLINE,0)
  25. void add_part (Module mp, char *s, Parttype type, Location *loc);
  26. typedef struct parent {
  27.     Module this;
  28.     struct parent *parent;
  29. } *Parent;
  30.  
  31. int expand (Module mp, int indent, int partial_distance, Parent parent, 
  32.             char *locformat, FILE *out);
  33.         /* expand a module, writing to file out */
  34. void resetloc(void);
  35. int printloc(FILE *fp, char *fmt, Location loc, int partial);
  36. void remove_final_newline (Module mp);
  37.         /* remove trailing newline that must be in module */
  38.